package io.lkt.modules.sys.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BUserShareArticleInfoDao;
import io.lkt.modules.sys.entity.BUserShareArticleInfoEntity;
import io.lkt.modules.sys.service.BUserShareArticleInfoService;


@Service("bUserShareArticleInfoService")
public class BUserShareArticleInfoServiceImpl extends ServiceImpl<BUserShareArticleInfoDao, BUserShareArticleInfoEntity> implements BUserShareArticleInfoService {
    @Autowired
    private BUserShareArticleInfoDao bUserShareArticleInfoDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BUserShareArticleInfoEntity> page = this.page(
                new Query<BUserShareArticleInfoEntity>().getPage(params),
                new QueryWrapper<BUserShareArticleInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageForUserId(Map<String, Object> params) {
        IPage<BUserShareArticleInfoEntity> page = this.page(
                new Query<BUserShareArticleInfoEntity>().getPage(params),
                new QueryWrapper<BUserShareArticleInfoEntity>()
                        .eq("user_id", params.get("userId"))
                        .orderByDesc("id")
        );

        return new PageUtils(page);
    }

    @Override
    public List<BUserShareArticleInfoEntity> getUserShareInfo(Map<String, Object> params) {
        return bUserShareArticleInfoDao.getUserShareInfo(params);
    }

    @Override
    public int getUserShareInfoTotal(Map<String, Object> params) {
        return bUserShareArticleInfoDao.getUserShareInfoTotal(params);
    }

    @Override
    public int getUserShareArticleCount(Integer userId) {
        return bUserShareArticleInfoDao.getUserShareArticleCount(userId);
    }

}
